<include file="public@header" />
</head>

<body>
    <div class="wrap js-check-wrap">

        <!-- 顶部标签区域 -->
        <ul class="nav nav-tabs">
            <php>
                $pageLimitArr = [5,10,15,20,30];
                $httpParamStatusAll = $httpParamStatusYes = $httpParamStatusNo = $httpParam;
                $httpParamStatusAll['status'] = 'all';
                $httpParamStatusYes['status'] = 'yes';
                $httpParamStatusNo['status'] = 'no';
            </php>
            <li <eq name="httpParam.status" value="all">class="active"</eq> ><a
                    href="{:url('index', $httpParamStatusAll)}">所有{$_title} </a></li>
            <li <eq name="httpParam.status" value="yes">class="active"</eq> ><a
                    href="{:url('index', $httpParamStatusYes)}">已发布{$_title} </a></li>
            <li <eq name="httpParam.status" value="no">class="active"</eq> ><a
                    href="{:url('index', $httpParamStatusNo)}">未发布{$_title} </a></li>
            <li><a href="{:url('add')}">添加{$_title}</a></li>
        </ul>

        <!-- 搜索功能区域 -->
        <form class="well form-inline margin-top-20 bg-white" method="get" action="{:url('index')}">
            <input type="hidden" name="limit" value="{$pageLimit}" />

            状态：
            <select class="form-control" name="status" style="width: 80px;">
                <option value='all' <eq name="httpParam.status" value="all">selected</eq> >全部</option>
                <option value='yes' <eq name="httpParam.status" value="yes">selected</eq> >已发布</option>
                <option value='no' <eq name="httpParam.status" value="no">selected</eq> >未发布</option>
            </select>
            &nbsp;&nbsp;

            排序：
            <select class="form-control" name="list_order_by" style="width: 140px;">
                <option value='list_order asc' <eq name="httpParam.list_order_by" value="list_order asc">selected</eq>
                    >排序-顺序</option>
                <option value='list_order desc' <eq name="httpParam.list_order_by" value="list_order desc">selected</eq>
                    >排序-倒序</option>
                <option value='id asc' <eq name="httpParam.list_order_by" value="id asc">selected</eq> >ID-顺序</option>
                <option value='id desc' <eq name="httpParam.list_order_by" value="id desc">selected</eq> >ID-倒序</option>
            </select>
            &nbsp;&nbsp;

            ID范围：
            <input type="text" class="form-control" name="id_start" value="{$httpParam.id_start|default=''}"
                style="width: 80px;" autocomplete="off">-
            <input type="text" class="form-control" name="id_end" value="{$httpParam.id_end|default=''}"
                style="width: 80px;" autocomplete="off">
            &nbsp; &nbsp;

            关键字：
            <input type="text" class="form-control" name="keyword" style="width: 200px;"
                value="{$httpParam.keyword|default=''}" placeholder="请输入关键字...">

            <input type="submit" class="btn btn-primary" value="确定" />

            <a class="btn btn-danger" href="{:url('index', array('limit'=>$pageLimit))}">清空</a>

        </form>

        <!-- 列表主体批量操作表单 -->
        <form class="js-ajax-form" action="" method="post">

            <!-- 批量操作按钮群 头部 -->
            <php>
                if (!function_exists('tableActions')) {
                function tableActions(){
            </php>
            <div class="table-actions">
                批量操作： 
                <button class="btn btn-primary btn-sm js-ajax-submit" type="submit"
                    data-action="admin/goods/brand/list/order">{:lang('SORT')}
                </button>
                <button class="btn btn-primary btn-sm js-ajax-submit" type="submit"
                    data-action="admin/goods/brand/status/1" data-subcheck="true">发布
                </button>
                <button class="btn btn-warning btn-sm js-ajax-submit" type="submit"
                    data-action="admin/goods/brand/status/0" data-subcheck="true">取消发布
                </button>
                <button class="btn btn-danger btn-sm js-ajax-submit" type="submit" data-action="{:url('delete')}"
                    data-subcheck="true" data-msg="您确定删除吗？">
                    {:lang('DELETE')}
                </button>
            </div>
            <php>
                }
                }
            </php>
            <!-- 批量操作按钮群 头部 -->
            {:tableActions()}

            <!-- 列表主体表格 -->
            <table class="table table-hover table-bordered table-list">
                <!-- 表格头部 -->
                <thead>
                    <tr>
                        <th width="15">
                            <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                        </th>
                        <th width="20">ID</th>
                        <th width="50">{:lang('SORT')}</th>
                        <th>品牌名</th>
                        <th>别名</th>
                        <th width="160">LOGO缩略图</th>
                        <th width="160">品牌官网</th>
                        <th width="70">状态</th>
                        <th width="95">操作</th>
                    </tr>
                </thead>
                <!-- 表格主体 -->
                <tbody>
                    <foreach name="listData" item="vo">
                        <tr>
                            <td title="ID:{$vo.id}">
                                <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x"
                                    name="ids[]" value="{$vo.id}">
                            </td>
                            <td>{$vo.id}</td>
                            <td>
                                <input name="list_orders[{$vo.id}]" type="text" size="3" value="{$vo.list_order}"
                                    class="input-order">
                            </td>
                            <td>{$vo.title}</td>
                            <td>{$vo.alias}</td>
                            <td>
                                <notempty name="vo.logo">
                                    <a
                                        href="javascript:parent.imagePreviewDialog('{:cmf_get_image_preview_url($vo.logo)}');">
                                        <i class="fa fa-photo fa-fw"></i>
                                    </a>
                                    <else />
                                    <i class="fa fa-close fa-fw"></i>
                                </notempty>
                            </td>
                            <td><a href="{$vo.url}" title="{$vo.url}" target="_blank">访问</a> ｜ 复制</td>
                            <td>
                                <notempty name="vo.status">
                                    <a data-toggle="tooltip" title="已发布"><i class="fa fa-check"></i></a>
                                    <else />
                                    <a data-toggle="tooltip" title="未发布"><i class="fa fa-close text-danger"></i></a>
                                </notempty>
                            </td>
                            <td>
                                <!-- <a class="btn btn-xs btn-primary" href="javascript:;"
                                    onclick="openGoodsBrandEditDialog(this)"
                                    data-href="{:url('edit',array('id'=>$vo['id']))}">{:lang('EDIT')}</a> -->
                                <a class="btn btn-xs btn-primary" href="{:url('edit',array('id'=>$vo['id']))}">{:lang('EDIT')}</a>
                                <a class="btn btn-xs btn-danger js-ajax-delete"
                                    href="admin/goods/brand/{$vo.id}/delete">{:lang('DELETE')}</a>
                            </td>
                        </tr>
                    </foreach>
                </tbody>
                <!-- 表格底部 -->
                <tfoot>
                    <tr>
                        <th width="15">
                            <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                        </th>
                        <th>ID</th>
                        <th width="50">{:lang('SORT')}</th>
                        <th>品牌名</th>
                        <th>别名</th>
                        <th width="160">LOGO缩略图</th>
                        <th width="160">品牌官网</th>
                        <th width="70">状态</th>
                        <th width="95">操作</th>
                    </tr>
                </tfoot>
            </table>

            <!-- 批量操作按钮群 底部 -->
            {:tableActions()}

            <!-- 分页 -->
            <ul class="pagination">
                {$pageHtml|default=''}
            </ul>
            &nbsp;&nbsp;&nbsp;
            <ul class="pagination">
                <li class="disabled"><span>共{$listTotal}条，每页</span></li>
                <php>
                    $pageLimitArr = [5,10,15,20,30];
                    $httpParamLimit = $httpParam;
                    foreach ($pageLimitArr as $key => $vo){
                    $httpParamLimit['limit'] = $vo;
                    $pageLimitActive = $httpParam['limit'] == $vo ? 'class="active"':'';
                </php>
                <li {$pageLimitActive}><a href="{:url('index', $httpParamLimit)}">{$vo}</a></li>
                <php>
                    }
                </php>
                <li class="disabled"><span>条</span></li>
            </ul>

        </form>

    </div>

    <script src="__STATIC__/js/admin.js?v={$_static_version}"></script>
    <script>
        function openGoodsBrandEditDialog(obj) {
            var $obj = $(obj);
            var href = $obj.data('href');
            parent.openIframeLayer(href, '编辑{$_title}', {
                area: GV.IS_MOBILE ? ['100%', '100%'] : ['95%', '95%'],
                offset: GV.IS_MOBILE ? ['0px', '0px'] : 'auto',
                btn: ['确定', '取消'],
                yes: function (index, layero) {
                    console.log(layero);
                    var iframeWin = parent.window[layero.find('iframe')[0]['name']];
                    //iframeWin.confirm();
                    parent.layer.close(index); //如果设定了yes回调，需进行手工关闭
                },
                end: function () {
                }
            });
        }
    </script>
</body>

</html>